//
// Created by liushuai on 18-7-22.
//

#include <iostream>
#include "flower.hpp"
flower::flower() {
    a = 100;
    b = 999;
}
flower::flower(const int & lower, const int & upper) {
    a = lower;
    b = upper;
}
bool flower::check(const int & num) const {
    if(num>=100&&num<=999)
    {
        return true;
    }
    else
    {
        return false;
    }

}
int flower::get_3(const int & num) const {
    int temp;
    temp = num/100;
    return temp;
}
int flower::get_2(const int & num) const {
    int temp;
    temp = num/10%10;
    return temp;
}
int flower::get_1(const int & num) const {
    int temp;
    temp = num%10;
    return temp;
}
int flower::computer(int &a3, int &a2, int &a1) const {
    long tmp = a1*a1*a1+a2*a2*a2+a3*a3*a3;
    return tmp;
}
int flower::get_a() const {
    return a;
}
int flower::get_b() const {
    return b;
}
void flower::get_flower() {
    int lower,upper;

    lower = get_a();
    upper = get_b();
    bool flag = true;
    for(int i=lower;i<=upper;i++)
    {

        if(isflower(i))
        {
//            std::cout<<"lower: "<<lower<<" upper: "<<upper<<"\n";
            std::cout<<i<<" ";
            flag = false;
        }
        continue;
    }
    if(flag)
    {
        std::cout<<"no"<<"\n";
    }

}
bool flower::isflower(const int &num) const {
    int a3,a2,a1;
    a3 = get_3(num);
    a2 = get_2(num);
    a1 = get_1(num);
    long result;
    result = computer(a3,a2,a1);
//    std::cout<<"实际数据"<<num<<" 百位："<<a3<<"十位："<<a2<<"个位："<<a1
//             <<"计算水仙花数:"<<result<<"\n";
//    std::cout<<"计算结果:"<<result<<" 实际数据"<<num<<"\n";
    if(num == result)
    {
        return true;
    }
    else
    {
        return false;
    }

}